package com.sansecy.customview.drawArc;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Calendar;

public class TestCase {
    /**
     * 将小数装换成百分比输出
     * 将double类型保留小数点后两位，转换成
     */
    public static void test() {
//      ================================================================================
        double f = 0.5585;
//        BigDecimal  b = new BigDecimal(f);
//        double f1 = b.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
//        System.out.println(f1);
        System.out.println(Integer.parseInt(new DecimalFormat("0").format(f * 100)) + "%");//百分比没有小数点
//      ===========================首选===================================================
        double result1 = 0.51111122111111;
        DecimalFormat df = new DecimalFormat("0.00%");
        String r = df.format(result1);
        System.out.println(r);//great
//      =================================================================================
        NumberFormat num = NumberFormat.getPercentInstance();
        num.setMaximumIntegerDigits(3);
        num.setMaximumFractionDigits(2);
        double csdn = 0.55555555555555555;
        System.out.println(num.format(csdn));//good
//      =================================================================================
        double result = 1;
        int temp = (int) (result * 1000);
        result = (double) temp / 10;
        System.out.println(result + "%");//100%  变成了  100.0%
    }

    public static void main(String[] args) {
//        test();
//        DecimalFormat df = new DecimalFormat("0.00%");
//        System.out.println(360 * 0.0001);
//        String r = df.format(0.0001 / 0.0102);
//        System.out.println(r);
//        String v = df.format(0.01 / 0.0102);
//        System.out.println(v);
//        System.out.println(0.98+0.98+98.04);
        Calendar c = Calendar.getInstance();
//        Date time = new Date();
//        c.setTime(time);
        for (int i = 7; i >0; i--) {
            int day = c.get(Calendar.DAY_OF_MONTH);
            String week = getDamaiDay( c.get(Calendar.DAY_OF_WEEK));
            System.out.println(day + "日 " + "周" + week);
            c.add(Calendar.DAY_OF_MONTH, -1);
        }
//        int day = c.get(Calendar.DAY_OF_MONTH);
//        int date = c.get(Calendar.DATE);
//        int week = c.get(Calendar.DAY_OF_WEEK)-1;
//        int weekOfYear = c.get(Calendar.WEEK_OF_YEAR);
//        int weekOfMonth = c.get(Calendar.WEEK_OF_MONTH);
//        int year = c.get(Calendar.YEAR);
//        int month = c.get(Calendar.MONTH);
//        System.out.println("本月第 " + weekOfMonth + " 周");
//        System.out.println("今年第 " + weekOfYear + " 周");
//        System.out.println("周 " + week + "");
//        System.out.println(year + "年 ");
//        System.out.println(month + "月 ");
//        System.out.println(day + "日 ");
//        System.out.println("DAY_OF_MONTH的同义词 date " + date);



    }
//    public static void sys() {
//        LocalDate date = LocalDate.of(2014, 3, 18);//2014-03-18
//        int year = date.getYear();//2014
//        Month month = date.getMonth();//MARCH
//        int day = date.getDayOfMonth();//18
//        DayOfWeek dow = date.getDayOfWeek();//TUESDAY
//        int len = date.lengthOfMonth();//31(这个月有多少天)
//        boolean leap = date.isLeapYear();//false(是不是闰年)
//    }

    private static String getDamaiDay(int date) {
        switch (date) {
            case Calendar.MONDAY:
                return "一";
            case Calendar.TUESDAY:
                return "二";
            case Calendar.WEDNESDAY:
                return "三";
            case Calendar.THURSDAY:
                return "四";
            case Calendar.FRIDAY:
                return "五";
            case Calendar.SATURDAY:
                return "六";
            case Calendar.SUNDAY:
                return "日";
            default:
                return "";
        }
    }
}